meson.build: Fix Vulkan library detection on Visual Studio
authorChun-wei Fan <fanchunwei@src.gnome.org>
Fri, 11 Aug 2017 09:05:55 +0000 (17:05 +0800)
committerChun-wei Fan <fanchunwei@src.gnome.org>
Fri, 15 Sep 2017 13:41:15 +0000 (21:41 +0800)
The Vulkan .lib file that is supplied by the LunarG Vulkan SDK is
vulkan-1.lib, not vulkan.lib, so make sure we look for the right
libraries when building on Visual Studio (I am not sure whether the
LunarG SDK will work for MinGW/mingw-w64 builds, as only Visual Studio
.lib files are provided).

Note that this will require one to set LIB and INCLUDE appropriately to
find the Vulkan .lib and header files, and possibly PATH if one's video
drivers do not contain the Vulkan runtime DLL.

https://bugzilla.gnome.org/show_bug.cgi?id=785210

meson.build

index 6d849b99108dd0fe7062aa4867a1820f3c92c3cb..7bc891247ad72c69171d31ed98821e15bba23cad 100644 (file)
@@ -508,12 +508,19 @@ cdata.set('HAVE_GIO_UNIX', giounix_dep.found())
 # TODO: move to gsk subfolder maybe? Or will it be used elsewhere too?
 have_vulkan = false
 vulkan_lib = []
+
+if cc.get_id() == 'msvc'
+  vulkan_libname = 'vulkan-1'
+else
+  vulkan_libname = 'vulkan'
+endif
+
 enable_vulkan = get_option('enable-vulkan')
 if enable_vulkan != 'no'
-  vulkan_lib = cc.find_library('vulkan', required: false)
+  vulkan_lib = cc.find_library(vulkan_libname, required: false)
   if vulkan_lib.found() and cc.has_function('vkCreateInstance', dependencies: vulkan_lib) and cc.has_header('vulkan/vulkan.h')
     have_vulkan = true
-    pc_gdk_extra_libs += ['-lvulkan']
+    pc_gdk_extra_libs += ['-l@0@'.format(vulkan_libname)]
   elif enable_vulkan == 'yes'
     error('Vulkan support not found, but was explicitly requested.')
   endif